#!/bin/bash

echo '安装软件包';
yum install mariadb mariadb-server python2-PyMySQL -y
echo '编辑mariadb-server文件 start';
echo '***************************************使用时修改bind-address';
cp /etc/my.cnf.d/mariadb-server.cnf{,.bak};
# bind-address 改成 0.0.0.0 ，监听所有端口 
echo '[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8'>/etc/my.cnf.d/mariadb-server.cnf;

echo '编辑mariadb-server文件 end';
echo '设置开机启动并立即运行。';
systemctl enable mariadb.service
systemctl start mariadb.service

echo '-----------------------------------------------------'
echo '              mariadb 配置完成                       '
echo '-----------------------------------------------------'
